const myApp = globalThis.myApp || {};

function extend(namespaace, path) {
    const parts = path.split('.');
    let parent = namespaace;
    for (let i = 0; i < parts.length; i++) {
        if (typeof parent[parts[i]] === "undefined") {
            parent[parts[i]] = {};
        }
        parent = parent[parts[i]];
    }
    return parent;
}

const mod = extend(myApp, 'modules.a.b.c');
console.log(mod);
console.log(myApp.modules);
console.log(myApp.modules.a);
console.log(myApp.modules.a.b);
